import sys
import numpy

id_string = '$Id: tim.py 124 2013-05-03 12:07:41Z T.R.M.vanMourik@gmail.com $'

print id_string.split()[2]," user ",id_string.split()[5]

print id_string.split()[2]


def check_line( input_string, atom ):
    if input_string.startswith( 'ATOM' ) and input_string.split()[2] == atom:   
            return True
    else:
            return False


file_name = sys.argv[1]

buffer = open( file_name, 'r' )

text_lines = buffer.readlines()

x_values = []
y_values = []
z_values = []
for line in text_lines:
    if check_line( line,'C' ):
        line_list = line.split()
        x_values.append( float(line_list[4]) )
        y_values.append( float(line_list[5]) )
        z_values.append( float(line_list[6]) )

x_avg = numpy.mean( x_values )
y_avg = numpy.mean( y_values )
z_avg = numpy.mean( z_values )

print 'The average x value is :',x_avg
print 'The average y value is :',y_avg
print 'The average z value is :',z_avg
